<template>
	<view class="login">
		<statusBar />
		<view class="login_user">登录</view>
		<!-- 用户名 -->
		<view class="user"><input type="text" value="" v-model="user" placeholder="用户名" /></view>
		<!-- 密码 -->
		<view class="user"><input type="password" value="" v-model="password" placeholder="密码" /></view>
		<view class="login-user" @tap="Login">登录</view>
	</view>
</template>
<script>
import { mapActions, mapState } from 'vuex';
import { toast } from '@/utils/toast';
import request from '@/utils/request';
import statusBar from '../../components/statusBar/statusBar.vue';
export default {
	components: {
		statusBar
	},
	data() {
		return {
			user: 'viva',
			password: '123'
		};
	},
	methods: {
		Login() {
			let _self = this
			uni.showLoading({
				title: '登录中',
				duration: 2000
			});
			request('/channel/login/loginin', 'POST', {
				userName: _self.user,
				passWord: _self.password
			}).then(res => {
				console.log(res.data, 777);
				if (res.data.code == 1) {
					console.log("222222")
					setTimeout(() => {
						uni.hideLoading();
					}, 500);
					setTimeout(function() {
						_self.$store.commit('user/LOGIN_INFO', res.data.data);
						uni.switchTab({
							url: '/pages/Setup/setup'
						});
					}, 1000);
				} else {
					toast(res.data.msg);
				}
			});
		}
	}
};
</script>
<style lang="scss" scoped>
.login {
	background: #ffffff !important;
	.login_user {
		font-size: 34upx;
		font-family: Source Han Sans CN;
		font-weight: bold;
		color: #333333;
		text-align: center;
		margin-top: 20upx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.user {
		width: 90%;
		margin: 0 auto;
		border: 1upx solid #eeeeee;
		height: 70upx;
	}
	.login-user {
		width: 100%;
		height: 112upx;
		background: rgba(53, 57, 76, 1);
		border-radius: 56upx;
		font-size: 34upx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: $bg1-color;
		margin-top: 73upx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
}
</style>
